﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HR.Appointments.Service.DisplayLists
{
    /// <summary>
    /// An object to better display orders in gridview
    /// </summary>
    public class OrderList
    {
        #region Constructors
        /// <summary>
        /// Wrapp the order into an orderlist object
        /// </summary>
        /// <param name="obj">A valid order entity</param>
        public OrderList(OrderEntity obj)
        {
            System.Diagnostics.Debug.Assert(obj != null, "OrderEntity is null");

            this.CompanyId = obj.Company.CompanyId;
            this.OrderID = obj.AppointmentId;
            this.CustomerName = obj.Person.Name;
			this.Date = obj.BookingDate.ToShortDateString();
            this.Time = obj.FromTime.ToString();

            switch (obj.Status)
            { 
                case OrderStatus.CONFIRMED:
                    IsBooked = "Staðfest";
                    break;
                case OrderStatus.DENIED:
                    IsBooked = "Hafnað";
                    break;
                case OrderStatus.UNCONFIRMED:
                    IsBooked = "Óstaðfest";
                    break;
                default:
                    IsBooked = "Staðfest";
                    break;
            }

            if (obj.Activity != null)
            {
                this.Action = obj.Activity.Name;
            }
            if(obj.Station != null)
            {
                this.Workstation = obj.Station.Name;
            }
            if (obj.Company != null)
            {
                this.CompanyName = obj.Company.Name;
            }
        }
        #endregion

        #region Public Properties
        /// <summary>
        /// Name of the customer who ordered
        /// </summary>
        public string CustomerName { get; set; }

        /// <summary>
        /// Name of the action the customer ordered
        /// </summary>
        public string Action { get; set; }

        /// <summary>
        /// The date the customer ordered
        /// </summary>
        public string Date { get; set; }

        /// <summary>
        /// The time the customer ordered
        /// </summary>
        public string Time { get; set; }

        /// <summary>
        /// The status of the orderd
        /// </summary>
        public string IsBooked { get; set; }

        /// <summary>
        /// The name of the workstation preforming the order
        /// </summary>
        public string Workstation { get; set; }

        /// <summary>
        /// Order identifier
        /// </summary>
        public int OrderID { get; set; }

        /// <summary>
        /// Company identifier
        /// </summary>
        public int CompanyId { get; set; }

        /// <summary>
        /// Name of the company
        /// </summary>
        public string CompanyName { get; set; }
        #endregion
    }
}
